package com.ss.android.wenda.answer.detail2;

import android.webkit.WebView;
import com.bytedance.common.b.UserAgentCompat;
import com.bytedance.common.utility.Logger;
import com.bytedance.common.utility.UIUtils;
import com.ss.android.action.a.a.Comment;
import com.ss.android.article.base.feature.detail2.article.a.NewDetailViewHolder;
import com.ss.android.article.base.feature.detail2.c.NewArticleDetailTTAndroidObject.AbsOnGetSeriesLinkPositionListener;
import com.ss.android.article.base.feature.model.Article;
import com.ss.android.article.base.utils.JSONObjectWrapper;
import com.ss.android.common.util.LoadUrlUtils;
import org.json.JSONException;
import org.json.JSONObject;

final class r extends AbsOnGetSeriesLinkPositionListener {
    private final NewAnswerDetailFragment a;

    r(NewAnswerDetailFragment arg1) {
        this.a = arg1;

    }

    public final void webviewContentResize(int newheight) {
        if(newheight >= 0 && (this.a.mAppData.aq()) && NewAnswerDetailFragment.a(this.a) != null && NewAnswerDetailFragment.a(this.a).mWebView != null) {
            int v0 = Math.min(((int)((((float) newheight)) * UserAgentCompat.getScale(NewAnswerDetailFragment.a(this.a).mWebView))), NewAnswerDetailFragment.a(this.a).mDetailScrollView.getHeight());
            if(NewAnswerDetailFragment.a(this.a).mWebView.getLayoutParams().height < v0) {
                NewAnswerDetailFragment.a(this.a).mWebView.getLayoutParams().height = v0;
                NewAnswerDetailFragment.a(this.a).mWebView.requestLayout();
            }
        }
    }

    public final void onDomReady(WebView webView) {
        if(Logger.debug()) {
            Logger.d(NewAnswerDetailFragment.TAG, "onDomReady");
        }

        if(!NewAnswerDetailFragment.e(this.a) && webView != null && this.a.mArticle != null && NewAnswerDetailFragment.a(this.a) != null) {
            this.a.q();
            UIUtils.setVisibility(this.a.h, 4);
            try {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("article_type", this.a.mArticle.articleType);
                if (!android.support.design.a.isTextEmpty(this.a.b)) {
                    jsonObject.put("log_extra", this.a.b);
                }
            }
            catch(JSONException jsonException) {
            }

            NewAnswerDetailFragment.r();
            if(this.a.mArticleDetail != null && this.a.mArticleDetail.spipeUser != null && this.a.mArticleDetail.spipeUser.mUserId == this.a.mSpipe.userId) {
                JSONObjectWrapper v1 = new JSONObjectWrapper();
                String v2 = "isAuthor";
                boolean v0_2 = this.a.mArticleDetail.spipeUser.mUserId == this.a.mSpipe.userId ? true : false;
                v1.put(v2, v0_2);
            }

            if(NewAnswerDetailFragment.a(this.a) == null) {
                return;
            }

            if(NewAnswerDetailFragment.a(this.a).mNewDetailPageExtra == null) {
                return;
            }

            if(NewAnswerDetailFragment.a(this.a).mNewDetailPageExtra.mArticleInfo == null) {
                return;
            }

            if(NewAnswerDetailFragment.a(this.a).mNewDetailPageExtra.mArticleInfo.wendaData == null) {
                return;
            }

            LoadUrlUtils.loadUrl(NewAnswerDetailFragment.a(this.a).mWebView, "javascript:set_info(\'" + NewAnswerDetailFragment.a(this.a).mNewDetailPageExtra.mArticleInfo.wendaData.json + "\')");
        }
    }

    public final void playNativeVideo(String vid, int arg2, int arg3, int arg4, int status, String arg6) {
    }

    public final void playVideo(String arg1, int arg2, int arg3, String arg4) {
    }

    public final void comment(String userName, String text, long commentId, int arg8) {
        if(this.a.isActive()) {
            NewDetailViewHolder v0 = NewAnswerDetailFragment.a(this.a);
            Article v1 = this.a.mArticle;
            if(v0 != null && v1 != null && !v1.mBanComment && this.a.mSpipe != null && NewAnswerDetailFragment.d(this.a) != null) {
                NewAnswerDetailFragment.b(this.a, arg8);
                NewAnswerDetailFragment.d(this.a).a(Comment.a(this.a.mSpipe, userName, text), commentId, true);
            }
        }
    }

    public final void onGetSeriesLinkPosition(int arg4) {
        NewAnswerDetailFragment.a(this.a, ((int)((((float)arg4)) * UserAgentCompat.getScale(NewAnswerDetailFragment.a(this.a).mWebView))));
    }

    public final void showTitleBarPgcLayout(boolean arg2) {
        if(!NewAnswerDetailFragment.b(this.a)) {
            NewAnswerDetailFragment.c(this.a);
        }

        NewAnswerDetailFragment.a(this.a, arg2);
    }
}

